import Vue from 'vue'
import MuseUI from 'muse-ui'
import 'muse-ui/dist/muse-ui.css'
import 'muse-ui/dist/theme-light.css'
import App from './App'
import router from './router'


Vue.config.productionTip = false
Vue.use(MuseUI);

window.global.$vm = new Vue({
  el: '#app',
  router,
  template: '<App/>',
  components: { App }
});

window.addEventListener('message',function(e){
  if((window.top==window)&&(e.source==window)){
    return;
  }
  let messageRouter = require('./common/MessageRouter');
  messageRouter.handler()
  if(window.$vm.$MessageHandler) {

    // window.$vm.$MessageHandler.handler(e.data,e.origin);
    var target = null;
    try{
      target =  e.source.name;
    }catch(err){
      target = e.origin;
    }
    window.$vm.$MessageHandler.handler(e.data,target);
  }
},false);
